/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.brain.cont.dto;

import com.brain.core.dto.ComunDto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.validation.constraints.Size;

/**
 *
 * @author Juan Verde since 28/09/2014
 */
@Entity
@Table(name = "TCONT_PLAN_CONTABLE_DETA")
public class PlanContableDetaDto extends ComunDto implements Serializable {

    private static final long serialVersionUID = 1L;
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_PLAN_CONTABLE_DETA")
    @TableGenerator(name = "SEQ_PLAN_CONTABLE_DETA", table = "TCORE_ENTIDAD", pkColumnName = "NOMBRE", valueColumnName = "CORRELATIVO", pkColumnValue = "TCONT_PLAN_CONTABLE_DETA", allocationSize = 1)
    @Id
    @Column(name = "ID")
    private Long id;
    @Column(name = "ID_PADRE")
    private Long idPadre;
    @Size(max = 250)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @Size(max = 1000)
    @Column(name = "DETALLE")
    private String detalle;
    @JoinColumn(name = "PLAN_CONTABLE", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne
    private PlanContableDto planContableDto;
    @Size(max = 15)
    @JoinColumns({
        @JoinColumn(name = "PLAN_CONTABLE", referencedColumnName = "PLAN_CONTABLE"),
        @JoinColumn(name = "CUENTA_PADRE", referencedColumnName = "CUENTA")
    })
    @ManyToOne
    private PlanContableDetaDto cuentaPadreDto;
    //@OneToMany(cascade = CascadeType.ALL, mappedBy = "cuentaPadreDto", fetch = FetchType.LAZY, orphanRemoval = true)
    //private List<PlanContableDetaDto> listaHijos;
    @Size(max = 15)
    @Column(name = "CUENTA")
    private String cuenta;
    @Size(max = 2)
    @Column(name = "CODIGO")
    private String codigo;
    @Column(name = "ESTADO")
    private Boolean estado;
    @Column(name = "CLASE")
    private Long clase;
    @Column(name = "TIPO")
    private String tipo;
    @Column(name = "ESTRUCTURA")
    private String estructura;
    @JoinColumn(name = "AMARRE1_CTA_D", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre1CtaD;
    @JoinColumn(name = "AMARRE1_CTA_H", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre1CtaH;
    @JoinColumn(name = "AMARRE2_CTA_D", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre2CtaD;
    @JoinColumn(name = "AMARRE2_CTA_H", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre2CtaH;
    @JoinColumn(name = "AMARRE3_CTA_D", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre3CtaD;
    @JoinColumn(name = "AMARRE3_CTA_H", referencedColumnName = "ID")
    @ManyToOne
    private PlanContableDetaDto amarre3CtaH;
    
    @Column(name = "AMARRE1")
    private Boolean amarre1;
    
    @Column(name = "AMARRE2")
    private Boolean amarre2;
    
    @Column(name = "AMARRE3")
    private Boolean amarre3;

    @Column(name = "AMARRE1_PORC")
    private BigDecimal amarre1Porc;
    
    @Column(name = "AMARRE2_PORC")
    private BigDecimal amarre2Porc;
    
    @Column(name = "AMARRE3_PORC")
    private BigDecimal amarre3Porc;
    
    @Column(name = "IND_REGISTRO")
    private Boolean indRegistro;
    
    public PlanContableDetaDto() {
        this.indRegistro = Boolean.TRUE;
    }
    public PlanContableDetaDto(PlanContableDetaDto p) {
        this.id = null;
        this.clase = p.getClase();
        this.tipo = p.getTipo();
        this.cuentaPadreDto = p;
        this.cuenta = p.getCuenta();
        this.descripcion = p.getDescripcion();
        this.estado = p.getEstado();
        this.planContableDto = p.getPlanContableDto();
        this.indRegistro = p.getIndRegistro();
        this.amarre1Porc = BigDecimal.ZERO;
        this.amarre2Porc = BigDecimal.ZERO;
        this.amarre3Porc = BigDecimal.ZERO;
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getIdPadre() {
        return idPadre;
    }

    public void setIdPadre(Long idPadre) {
        this.idPadre = idPadre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getDetalle() {
        return detalle;
    }

    public void setDetalle(String detalle) {
        this.detalle = detalle;
    }

    public PlanContableDetaDto getCuentaPadreDto() {
        return cuentaPadreDto;
    }

    public void setCuentaPadreDto(PlanContableDetaDto cuentaPadreDto) {
        this.cuentaPadreDto = cuentaPadreDto;
    }

    /*public List<PlanContableDetaDto> getListaHijos() {
        return listaHijos;
    }

    public void setListaHijos(List<PlanContableDetaDto> listaHijos) {
        this.listaHijos = listaHijos;
    }*/

    public String getCuenta() {
        return cuenta;
    }

    public void setCuenta(String cuenta) {
        this.cuenta = cuenta;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public Boolean getEstado() {
        return estado;
    }

    public void setEstado(Boolean estado) {
        this.estado = estado;
    }

    public PlanContableDto getPlanContableDto() {
        return planContableDto;
    }

    public void setPlanContableDto(PlanContableDto planContableDto) {
        this.planContableDto = planContableDto;
    }

    public Long getClase() {
        return clase;
    }

    public void setClase(Long clase) {
        this.clase = clase;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getEstructura() {
        return estructura;
    }

    public void setEstructura(String estructura) {
        this.estructura = estructura;
    }

    public PlanContableDetaDto getAmarre1CtaD() {
        return amarre1CtaD;
    }

    public void setAmarre1CtaD(PlanContableDetaDto amarre1CtaD) {
        this.amarre1CtaD = amarre1CtaD;
    }

    public PlanContableDetaDto getAmarre1CtaH() {
        return amarre1CtaH;
    }

    public void setAmarre1CtaH(PlanContableDetaDto amarre1CtaH) {
        this.amarre1CtaH = amarre1CtaH;
    }

    public PlanContableDetaDto getAmarre2CtaD() {
        return amarre2CtaD;
    }

    public void setAmarre2CtaD(PlanContableDetaDto amarre2CtaD) {
        this.amarre2CtaD = amarre2CtaD;
    }

    public PlanContableDetaDto getAmarre2CtaH() {
        return amarre2CtaH;
    }

    public void setAmarre2CtaH(PlanContableDetaDto amarre2CtaH) {
        this.amarre2CtaH = amarre2CtaH;
    }

    public PlanContableDetaDto getAmarre3CtaD() {
        return amarre3CtaD;
    }

    public void setAmarre3CtaD(PlanContableDetaDto amarre3CtaD) {
        this.amarre3CtaD = amarre3CtaD;
    }

    public PlanContableDetaDto getAmarre3CtaH() {
        return amarre3CtaH;
    }

    public void setAmarre3CtaH(PlanContableDetaDto amarre3CtaH) {
        this.amarre3CtaH = amarre3CtaH;
    }

    public Boolean getAmarre1() {
        return amarre1;
    }

    public void setAmarre1(Boolean amarre1) {
        this.amarre1 = amarre1;
    }

    public Boolean getAmarre2() {
        return amarre2;
    }

    public void setAmarre2(Boolean amarre2) {
        this.amarre2 = amarre2;
    }

    public Boolean getAmarre3() {
        return amarre3;
    }

    public void setAmarre3(Boolean amarre3) {
        this.amarre3 = amarre3;
    }

    public BigDecimal getAmarre1Porc() {
        return amarre1Porc;
    }

    public void setAmarre1Porc(BigDecimal amarre1Porc) {
        this.amarre1Porc = amarre1Porc;
    }

    public BigDecimal getAmarre2Porc() {
        return amarre2Porc;
    }

    public void setAmarre2Porc(BigDecimal amarre2Porc) {
        this.amarre2Porc = amarre2Porc;
    }

    public BigDecimal getAmarre3Porc() {
        return amarre3Porc;
    }

    public void setAmarre3Porc(BigDecimal amarre3Porc) {
        this.amarre3Porc = amarre3Porc;
    }

    public Boolean getIndRegistro() {
        return indRegistro;
    }

    public void setIndRegistro(Boolean indRegistro) {
        this.indRegistro = indRegistro;
    }
    
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlanContableDetaDto)) {
            return false;
        }
        PlanContableDetaDto other = (PlanContableDetaDto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.brain.cont.dto.PlanContableDetaDto[ id=" + id + " ]";
    }
}
